package com.mcx.modules.proto;

import com.mcx.modules.common.IProto;
import com.mcx.modules.common.MMO_DataStream;

import java.io.*;
import java.util.*;

/**
 * 客户端发送进入世界地图场景消息
 */
public class WorldMap_RoleEnterProto implements IProto
{
    private static MMO_DataStream dataStream = new MMO_DataStream();

    @Override
    public short getProtoCode() { return 13001; }

    public Integer WorldMapSceneId; //世界地图场景编号

    public byte[] ToArray() {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try (DataOutputStream outputStream = new DataOutputStream(out)) {
            dataStream.outputStream = outputStream;
            dataStream.WriteShort(getProtoCode());
            dataStream.WriteInt(WorldMapSceneId);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return out.toByteArray();    }
    public static WorldMap_RoleEnterProto GetProto(byte[] buffer) {
        WorldMap_RoleEnterProto proto = new WorldMap_RoleEnterProto();
        try (DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(buffer))) {
            dataStream.inputStream = inputStream;
            proto.WorldMapSceneId = dataStream.ReadInt();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return proto;
    }
}